using System.Collections.Generic;

namespace RollManager.Library
{
    partial class Database
    {
        public static void AddServerGroup( string name )
        {
            runQuery( "AddServerGroup", name );
        }

        public static void AddServerToGroup( int serverGroupId, int serverId, int order )
        {
            runQuery( "AddServerToGroup", serverGroupId, serverId, order );
        }

        public static void ClearServerGroup( int serverGroupId )
        {
            runQuery( "ClearServerGroup", serverGroupId );
        }

        public static void DeleteServerGroup( int serverGroupId )
        {
            runQuery( "DeleteServerGroup", serverGroupId );
        }

        public static ServerGroup GetServerGroup( int serverGroupId )
        {
            List<ServerGroup> groups = runMapper<ServerGroup>( "GetServerGroup", serverGroupId );
            if( groups.Count == 0 )
            {
                return null;
            }

            return groups[ 0 ];
        }

        public static List<ServerGroup> GetServerGroups()
        {
            return runMapper<ServerGroup>( "GetServerGroups" );
        }

        public static void SaveServerGroup( ServerGroup group )
        {
            runQuery( "SaveServerGroup", group.Id, group.Name );
        }
    }
}
